import { QXEvent } from "qx-util";
import { IParam, DrbarActionType, IDrbarAbility, IDrbarControllerParams, IDrbarStore, DrbarController, ICtrlEvent, IDrbarController, IDrbarModel } from "@/core";
import { useDrbarAction, useDrbarBasic, useDrbarControllerParams, useDrbarProps } from "@/hooks/widget/use-drbar";
import { model } from "./default-drbar-model";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@DRBAR}}-drbar/{{spinalCase ctrl.codeName}}-drbar-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...useDrbarProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...useDrbarBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...useDrbarAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<DrbarActionType, IDrbarAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<DrbarActionType, IDrbarAbility>>,
    otherParams: IParam = {},
): IDrbarController<IDrbarStore, IDrbarAbility> {
	const params: IDrbarControllerParams<DrbarActionType, IDrbarAbility> =
		useDrbarControllerParams<IDrbarStore, IDrbarModel>(model, props, evt, otherParams);
  	return new DrbarController(params);
}